home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Samples / Media / EarthDispMap.fx < prev    next >
Encoding:
Text File  |  2002-11-12  |  1.7 KB  |  58 lines

  1. // Shaders used by the BumpEarth D3D sample
  2.  
  3. // Displacement mapping + bump mapping shader
  4. //
  5. // Float constants used:
  6. //  C0 - C3 - transformation matrix
  7. //  C4.x    - scale factor
  8. //
  9. VertexShader EarthBumpMap = asm
  10. {
  11.     vs_1_1
  12.     // Input declaration
  13.     dcl_position0 v0
  14.     dcl_texcoord0 v1
  15.     dcl_sample0   v2
  16.     dcl_normal0   v3
  17.     dcl_texcoord1 v4
  18.  
  19.     // Main function
  20.     mul r0, v3, c4.x    // Multiply normal by a scale factor
  21.     mul r0, r0, v2.x    // Multiply normal by the displacement value
  22.     add r0, v0, r0      // Add normal to position
  23.     mov r0.w, v0.w      // W component is taken from the input position
  24.     m4x4 oPos, r0, c0   // Transform new position to the projection space
  25.     mov oT0, v4         // Copy input texture coordinates
  26.     mov oT1, v4         // Copy input texture coordinates
  27.     mov oT2, v1         // Copy input texture coordinates
  28. };
  29.  
  30. // Displacement mapping + no bump mapping shader
  31. //
  32. // Float constants used:
  33. //  C0 - C3 - transformation matrix
  34. //  C4.x    - scale factor
  35. //
  36. VertexShader EarthNoBumpMap = asm
  37. {
  38.     vs_1_1
  39.     // Input declaration
  40.     dcl_position0 v0
  41.     dcl_texcoord0 v1
  42.     dcl_sample0   v2
  43.     dcl_normal0   v3
  44.     dcl_texcoord1 v4
  45.  
  46.     // Main function
  47.     mul r0, v3, c4.x    // Multiply normal by a scale factor
  48.     mul r0, r0, v2.x    // Multiply normal by the displacement value
  49.     add r0, v0, r0      // Add normal to position
  50.     mov r0.w, v0.w      // W component is taken from the input position
  51.     m4x4 oPos, r0, c0   // Transform new position to the projection space
  52.     mov oT0, v4         // Copy input texture coordinates
  53.     mov oT1, v1      
  54. };
  55.  
  56. technique DisplacementMapping {}
  57.  
  58.